//元组可以充当函数的参数和返回值

use std::fmt;
use std::fmt::{Display, write};

// 翻转元组
pub fn reverse(pair:(i32,bool)) -> (bool,i32) {
    let(integer,boolean) = pair;
    (boolean,integer)
}



#[derive(Debug)]
struct Matrix(f32,f32,f32,f32);

impl fmt::Display for Matrix {
    fn fmt(&self,f: &mut fmt::Formatter) -> fmt::Result {
        writeln!(f,"( {} {} )",self.0,self.1);
        writeln!(f,"( {} {} )",self.2,self.3)
    }
}

pub fn tuple_use() {
    let long_tuple = (1u8,2u16,3u32,4u64,
                      -1i8,-2i16,-3i32,-4i64,
                      0.1f32,0.2f64,'a',true);

    println!("long tuple first value: {}",long_tuple.0);

    let AA = Matrix(2f32,23f32,4f32,5f32);
    println!("Display\n{}",AA)
}
